package com.woniuxy.store.core.controller;


import com.woniuxy.common.CommonResult;
import com.woniuxy.store.core.model.MdSs;
import com.woniuxy.store.core.service.MdSsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gmx
 * @since 2021-06-29
 */
@RestController
@RequestMapping("/mdSs")
public class MdSsController {

    @Autowired
    MdSsService mdSsService;

    //查新所有二级菜单列表
    @GetMapping("/selectAll")
    public CommonResult selectAll(){
        List<MdSs> ssList=this.mdSsService.list();
        return CommonResult.success(ssList);
    }

    //查询一个二级菜单
    @GetMapping("/selectOne/{ssId}")
    public CommonResult selectOne(@PathVariable("ssId") int ssId) {
        MdSs  mdSs=this.mdSsService.getById(ssId);
        return CommonResult.success(mdSs);
    }

    //修改一个二级菜单信息
    @PostMapping("updateOne")
    public CommonResult updateOne(@RequestBody MdSs mdSs){
        boolean b=  this.mdSsService.updateById(mdSs);
        if(b){
            return CommonResult.success("更新成功");}
        else {
            return CommonResult.fail();
        }
    }

    //增加一个二级菜单连接数据
    @PostMapping("/insertOne")
    public CommonResult insertOne(@RequestBody MdSs mdSs){
        this.mdSsService.insertOne(mdSs);
        return CommonResult.success("插入成功");
    }
    //删除一个二级菜单连接
    @GetMapping("delectOne/{ssId}")
    public CommonResult delectOnestore(@PathVariable("ssId") int ssId) {
        this.mdSsService.delectOne(ssId);
        return CommonResult.success("注销成功");
    }

}

